{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "D\n",
      "B\n",
      "C\n",
      "A\n"
     ]
    }
   ],
   "source": [
    "class A:\n",
    "    def __init__(self) -> None:\n",
    "        print(\"A\")\n",
    "class B(A):\n",
    "    def __init__(self) -> None:\n",
    "        print(\"B\")\n",
    "        super().__init__()\n",
    "class C(A):\n",
    "    def __init__(self) -> None:\n",
    "        print(\"C\")\n",
    "        super().__init__()\n",
    "class D(B, C):\n",
    "    def __init__(self) -> None:\n",
    "        print(\"D\")\n",
    "        super().__init__()\n",
    "\n",
    "d = D()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "super()按mro顺序调用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(__main__.D, __main__.B, __main__.C, __main__.A, object)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "D.__mro__"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "grammer-study-12-env",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
